import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
   // {
   //  title: '流程状态',
   //  align:"center",
   //  dataIndex: 'bpmStatus',
   //   show:false,
   // },
   {
    title: '仓库',
    align:"center",
    dataIndex: 'cstordocc'
   },
   {
    title: '仓库id',
    align:"center",
    dataIndex: 'cstordocid'
   },
   {
    title: '入库类型',
    align:"center",
    dataIndex: 'ctrantype'
   },
   {
    title: '业务员',
    align:"center",
    dataIndex: 'cpsnname'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '流程状态',
    field: 'bpmStatus',
    component: 'Input',
    show: false,
  },
  {
    label: '仓库',
    field: 'cstordocc',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"stordoc",
            fieldConfig: [
                { source: 'name', target: 'cstordocc' },
                { source: 'id', target: 'cstordocid' },
            ],
            multi:false
        }
    },


  },
  {
    label: '仓库id',
    field: 'cstordocid',
    component: 'Input',
    show: false,
  },
  {
    label: '业务员id',
    field: 'cpsnid',
    component: 'Input',
    show: false
  },
  {
    label: '入库类型',
    field: 'ctrantype',
    component: 'Input',
  },
  {
    label: '业务员',
    field: 'cpsnname',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"user",
            fieldConfig: [
                { source: 'name', target: 'cpsnname' },
                { source: 'id', target: 'cpsnid' },
            ],
            multi:false
        }
    },

  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const iaI2bilBColumns: JVxeColumn[] = [
    {
      title: '流程状态',
      key: 'bpmStatus',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      show: false,
    },
    {
      title: '物料id',
      key: 'cinventoryid',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      show: false,
    },
    {
      title: '物料',
      key: 'cinventory',
      type: JVxeTypes.popup,
      popupCode:"bd_material",
      fieldConfig: [
        { source: 'name', target: 'cinventory' },
        { source: 'code', target: 'cinventorycode' },
        { source: 'id', target: 'cinventoryid' },
      ],

      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '物料编码',
      key: 'cinventorycode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '批次号',
      key: 'vbatchcode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '数量',
      key: 'nastnum',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '单价',
      key: 'nprice',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '金额',
      key: 'nmny',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源单据类型',
      key: 'vsrctype',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源单据号',
      key: 'vsrccode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      show: false,
    },
    {
      title: '来源单据',
      key: 'csrcid',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      show: false,
    },
    {
      title: '来源单据分录',
      key: 'csrcbid',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      show: false,
    },
    {
      title: '赠品标志',
      key: 'blargessflag',
      type: JVxeTypes.checkbox,
      customValue: ['Y', 'N'],
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '主表id',
      key: 'idH',
      type: JVxeTypes.input,
      disabled:true,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      show: false,
    },
  ]


// 高级查询数据
export const superQuerySchema = {
  bpmStatus: {title: '流程状态',order: 0,view: 'text', type: 'string',},
  cstordocc: {title: '仓库',order: 1,view: 'popup', type: 'string',code: 'stordoc', orgFields: 'name', destFields: 'cstordocc', popupMulti: false,},
  cstordocid: {title: '仓库id',order: 2,view: 'text', type: 'string',},
  ctrantype: {title: '入库类型',order: 4,view: 'text', type: 'string',},
  cpsnname: {title: '业务员',order: 5,view: 'popup', type: 'string',code: 'user', orgFields: 'name', destFields: 'cpsnname', popupMulti: false,},
  //子表高级查询
  iaI2bilB: {
    title: '入库单子表',
    view: 'table',
    fields: {
        bpmStatus: {title: '流程状态',order: 0,view: 'text', type: 'string',},
        cinventoryid: {title: '物料id',order: 1,view: 'text', type: 'string',},
        cinventory: {title: '物料',order: 2,view: 'popup', type: 'string',code: 'bd_material', orgFields: 'name', destFields: 'cinventory', popupMulti: false,},
        cinventorycode: {title: '物料编码',order: 3,view: 'text', type: 'string',},
        vbatchcode: {title: '批次号',order: 4,view: 'text', type: 'string',},
        nastnum: {title: '数量',order: 5,view: 'number', type: 'number',},
        nprice: {title: '单价',order: 6,view: 'number', type: 'number',},
        nmny: {title: '金额',order: 7,view: 'number', type: 'number',},
        vsrctype: {title: '来源单据类型',order: 8,view: 'text', type: 'string',},
        vsrccode: {title: '来源单据号',order: 9,view: 'text', type: 'string',},
        csrcid: {title: '来源单据',order: 10,view: 'text', type: 'string',},
        csrcbid: {title: '来源单据分录',order: 11,view: 'text', type: 'string',},
        blargessflag: {title: '赠品标志',order: 12,view: 'switch', type: 'string',},
        idH: {title: '主表id',order: 13,view: 'text', type: 'string',},
    }
  },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
